/***
	templates: default
	name: utilitydlg.js
	designer: kukei
	Copyright(C) 2011 SupDo.com
	Create Date: 2012-03-23
	Modify Date: 2012-03-23
***/
var fcimgDlag;
var fcimgPreDlag;
function openImgDlg(retID, operDlg){
	fcimgDlag = $.dialog({
		id:'fcimgDlag', title:'封面图片选择',
		content: "url:/imgsImage/images.html",
		width: '680px', height: '400px',
		max: false, min: false, lock: true, cancel: true,
		ok: function(){
			preimgSrc = $('#imgSelected', fcimgDlag.iwin.document.body).val();
			if(preimgSrc){
				if(retID){
					//如果operDlg是null，则说明需要控制的控件在当前页面
					if(operDlg) $('#'+retID, operDlg.iwin.document.body).val(preimgSrc);	else $('#'+retID).val(preimgSrc);
					
				}else{
					$('#preFrontcover').attr('src',preimgSrc);
					$('#id_frontcover').val(preimgSrc);
				}
			}
		}
	})
}
function clearImg(retID, operDlg){
	if(retID){
		if(operDlg) $('#'+retID, operDlg.iwin.document.body).val('');	else $('#'+retID).val('');
	}else{
		$('#preFrontcover').attr('src','');
		$('#id_frontcover').val('');
	}
}
function openPreImgDlg(imgsrc){
	if(imgsrc){
		var src_array =imgsrc.split("/");
		var imgPreHtml = "<div><center><img style=\"max-width:500px;width: expression(this.width > 500 ? '500' : true);\" id=\"preFrontcover\" src=\""+imgsrc+"\" /></center></div>";
		fcimgPreDlag = $.dialog({
			id:'fcimgPre', title:'图片预览',
			content: imgPreHtml,
			max: false, min: false, lock: false,
			ok: true, cancel: true
		})
	}
}
function bindFrontcover(){$('#id_frontcover').bind('click', function(){if($('#id_frontcover').val()!=''){openPreImgDlg($('#id_frontcover').val())}});}
function bindPreImg(retID, operDlg){
	var PreImg = null;
	if(operDlg)  PreImg = $('#'+retID, operDlg.iwin.document.body); else PreImg = $('#'+retID);
	PreImg.bind('click', function(){
		var PreImg = null;
		if(operDlg)  PreImg = $('#'+retID, operDlg.iwin.document.body); else  PreImg = $('#'+retID);
		if(PreImg.val()!=''){openPreImgDlg(PreImg.val())}
	});
}